<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="css/loginRegister.css"/>
	<title>iBOOK-注册</title>
</head>
<body id="registerPage">
	<form name="form1" id="form1">
		<p>
			<input type="text" id="yhm" v-model="user.yhm" placeholder="用户名" />
		</p>
		<p>
			<input type="password" id="pwd" v-model="user.pwd" placeholder="密码" maxlength="6"/>
		</p>
		<p>
			<input type="password" id="pwd2" v-model="user.pwd2" placeholder="确认密码" maxlength="6"/>
		</p>
		<p>
			<input type="button" value="注册" id="register" @click="doRegister"/>
		</p>
		<p>
			<a href="login.html" id="left">已有账号</a>
			<span id="right">
				<a href="index.html">网站首页</a> 
			</span>
		</p>
	</form>
</body>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
Vue.createApp({
	data() {
		return {
			user: {
				yhm: "",
				pwd: "",
				pwd2:''
			}
		}
	},
	methods:{
		async doRegister(){
			const {data} = await axios.post('/bms/user',this.user);
			if(data == 1){
				// 注册成功跳转到 登录 页面
				location = "/bms/login.html";
			}else{
				alert("注册失败！");
			}
		}
	}
}).mount('#registerPage');
</script>
</html>